function [ EC ] = APEbatchgenerateoverview()

% generates overviews for all files in chosen folder using
% APEgenerateoverview

%% ===== CONFIG =====

oldpath = cd;

%% ===== CODE =====

[FileName,PathName,FilterIndex] = uigetfile('*.mat');
if isequal(FileName,0)
   disp('User selected Cancel')
   EC = 1;
   return
else
   disp(['User selected ', fullfile(PathName, FileName)])
end
cd(PathName)
filelist=dir('*.mat');      % Detect all available .mat files

if ~exist('APEout','dir')
    mkdir('APEout')
    cd('APEout')
else
    cd('APEout')
end

for i=1:length(filelist)
    APEgenerateoverview(['../',filelist(i).name])
    close all
end

%% ===== END =====
EC = 0;
cd(oldpath);
close all